//
//  RW_SetupItemCollectionViewCell.m
//  Yule
//
//  Created by 王亮 on 2021/1/22.
//  Copyright © 2021 Yule.dating. All rights reserved.
//

#import "RW_SetupItemCollectionViewCell.h"
@interface RW_SetupItemCollectionViewCell ()
@property (nonatomic,strong) UILabel *title_label;
@property (nonatomic,strong) UILabel *desc_label;


@end
@implementation RW_SetupItemCollectionViewCell
#pragma --mark 夫对象实现数据绑定方法
-(void)bind_row_data:(WLBaseCollectionViewLayerRow *)sender{
    if ([sender.data isKindOfClass:RW_SetupModel.class]){
        RW_SetupModel *model = sender.data;

        self.title_label.text = model.showTitle;
        self.desc_label.text = model.showDesc;
        
        if (model.type == Setup_Cell_Type_Login_Out){
            self.title_label.textColor = UIColor.whiteColor;
            self.title_label.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];

            self.backgroundColor = UIColor.redColor;
            self.layer.cornerRadius = 8;
            
            [self.title_label mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.center.mas_equalTo(self);
            }];
        } else {
            self.title_label.textColor = [UIColor colorWithHexString:@"333333"];
            self.title_label.font = [UIFont systemFontOfSize:14];

            self.backgroundColor = UIColor.whiteColor;
            self.layer.cornerRadius = 0;
            
            [self.title_label mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(self);
                make.left.mas_equalTo(self).mas_offset(15);
            }];
        }
    }
}
-(void)bind_delegate:(id)sender{
    //    self.delegate = sender;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = UIColor.whiteColor;
        
        [self addSubview:self.title_label];
        [self addSubview:self.desc_label];
        
        [self.title_label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self);
            make.left.mas_equalTo(self).mas_offset(15);
        }];
        [self.desc_label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self);
            make.right.mas_equalTo(self).mas_offset(-15);
            make.width.mas_equalTo(self).multipliedBy(0.5f);
        }];
    }
    return self;
}


-(UILabel *)title_label{
    if (!_title_label){
        _title_label = [[UILabel alloc]init];
        _title_label.textColor = [UIColor colorWithHexString:@"333333"];
        _title_label.font = [UIFont systemFontOfSize:14];
    }
    return _title_label;
}
-(UILabel *)desc_label{
    if (!_desc_label){
        _desc_label = [[UILabel alloc]init];
        _desc_label.textColor = [UIColor colorWithHexString:@"999999"];
        _desc_label.font = [UIFont systemFontOfSize:12];
        _desc_label.textAlignment = NSTextAlignmentRight;
    }
    return _desc_label;
}
@end
